<?php

namespace app\widgets;

use yii;

class AppMenuWidget extends yii\widgets\Menu {

    public $encodeLabels = FALSE;
    public $activeCssClass = 'active';
    public $options = ['class' => 'nav nav-menu'];
    public $itemOptions = ['class' => 'nav-item'];
    public $linkTemplate = '<a class="nav-link" href="{url}">{label}</a>';

    public function init() {
        parent::init();

        if ($this->route === null && Yii::$app->controller !== null) {
            $this->route = Yii::$app->controller->getRoute();
            $this->route = str_replace(['site/', 'index'], ['', ''], $this->route);
        }
        $this->items = [
            ['label' => '首页', 'url' => ['/']],
//            ['label' => '韩漫', 'url' => ['/country/kr']],
//            ['label' => '日漫', 'url' => ['/country/cn']],
            ['label' => '更新', 'url' => ['/update']],
//            ['label' => '排行', 'url' => ['site/top']],
            ['label' => '分类', 'url' => ['/category']],
        ];
    }

    protected function isItemActive($item) {
        return parent::isItemActive($item);
    }
}